//
//  GuiderDetailHeaderView.m
//  ImGuider
//
//  Created by 王鹏宇 on 2017/4/19.
//  Copyright © 2017年 imguider. All rights reserved.
//

#import "GuiderDetailHeaderView.h"
#import "StarRateView.h"
#import "GuiderIconView.h"

@interface GuiderDetailHeaderView()

@property (weak, nonatomic) IBOutlet GuiderIconView *guiderHeaderView;


@property (weak, nonatomic) IBOutlet UILabel *nameLabel;

@property (weak, nonatomic) IBOutlet UILabel *guiderIntroduceLabel;

@property (weak, nonatomic) IBOutlet UILabel *viewCountLabel;

@property (weak, nonatomic) IBOutlet UILabel *visitCountLabel;

@property (weak, nonatomic) IBOutlet UILabel *faourCountLabel;

@property (nonatomic, copy)NSString * iconURL;

@property (weak, nonatomic) IBOutlet UILabel *AuthenticationLabel;


@property (weak, nonatomic) IBOutlet NSLayoutConstraint *AuthenticationLabelH;

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *toTopSpace;

@end

@implementation GuiderDetailHeaderView

- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.AuthenticationLabel.textColor = kThemeColor;
    self.nameLabel.textColor = kTitleColor;
    self.guiderIntroduceLabel.textColor = kContentColor;
    self.viewCountLabel.textColor = kContentColor;
    self.visitCountLabel.textColor = kContentColor;
    self.faourCountLabel.textColor = kContentColor;
    self.viewCountLabel.text = @"";
    self.visitCountLabel.text = @"";
    self.faourCountLabel.text = @"";
    
    self.toTopSpace.constant = kNavigationBarHeight + 6;
    UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(lookBigPic:)];
    
    self.AuthenticationLabel.textColor = kThemeRedColor;
    [self.guiderHeaderView addGestureRecognizer:tap];
    // Initi
}

- (void)lookBigPic:(UITapGestureRecognizer *)tap{
    
    if (self.iconURL.length > 0) {
        
        IGLog(@"%@",self.iconURL);
        if (_delegate && [_delegate respondsToSelector:@selector(goBigPicVCWith:)]) {
            [_delegate goBigPicVCWith:self.iconURL];
        }
    }
    
}

- (void)configDataWithGuiderModel:(GuiderCardModel *)model {
  
    self.iconURL = model.headimg;
    self.guiderHeaderView.headerImageName = model.headimg;
    self.guiderHeaderView.userInteractionEnabled = YES;
    self.nameLabel.text = model.realname;
    if (model.introduction.length > 0) {
        self.guiderIntroduceLabel.attributedText = [IGUtils attributedStringText:model.introduction font:Font(12) color:kContentColor lineSpacing:lineSpace];
    }
    
    if (model.viewcount != nil) {
        self.viewCountLabel.text = [NSString stringWithFormat:@"%@",model.viewcount];
    }
    
    if (model.visitcount != nil) {
        self.visitCountLabel.text = [NSString stringWithFormat:@"%@",model.visitcount];
    }
    
    if (model.favourcount != nil) {
        self.faourCountLabel.text = [NSString stringWithFormat:@"%@",model.favourcount];
    }
    
    
    self.guiderHeaderView.vip = model.vip;
    if (model.certificate.length) {
        self.AuthenticationLabelH.constant = 20;
        self.AuthenticationLabel.text = model.certificate;
    }else {
        self.AuthenticationLabel.text = @"";
        self.AuthenticationLabelH.constant = 0;
    }
}

@end
